package switchviz.recording;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import java.io.IOException;

import javax.swing.JPanel;

import switchviz.core.ResourceManager;
import switchviz.gui.component.JLabeldComponent;
import switchviz.util.FileOperations;


public class RecordConfigurationPanel extends JPanel
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 7826512829158793331L;
	private ReplayPanel _replaypanel = null;
	private JLabeldComponent _txtsig = null;
	
	public RecordConfigurationPanel()
	{
		initialize();
	}
	
	public ReplayPanel getReplayPanel()
	{
		if(_replaypanel == null)
		{
			_replaypanel = new ReplayPanel();
		}
		return _replaypanel;
	}
	
	public void setReplayPanel(RecordDataModel rdm)
	{
		getReplayPanel().setRecordModel(rdm);
	}
	
	public void setSignal(File file) throws IOException
	{
		if(!file.exists()) return;
		_txtsig.getTextArea().read(FileOperations.getISOReader(file), file);
	}
	
	private void initialize()
	{
		this.setLayout(ResourceManager.getInstance().getBorderLayout());
		
		_txtsig = new JLabeldComponent("", JLabeldComponent.TEXTAREA, new Dimension(0, 0));
		_txtsig.getTextArea().setEditable(false);
		this.add(getReplayPanel(), BorderLayout.NORTH);
		this.add(_txtsig, BorderLayout.CENTER);
	}
}
